package org.byteDance.l162;

/**
 * @Author yu
 * @Date 2022/3/6
 */
public class Solution {

    public static void main(String[] args) {

    }

    public int findPeakElement(int[] nums) {
        if (nums.length == 0) {
            return 0;
        }

        int left = 0, right = nums.length - 1, mid = 0;

        while (left < right) {
            mid = left + right >> 1;

            if (nums[mid] > nums[mid + 1]) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }

        return left;
    }

}
